<?
include_once('db_setup.php');
//$table = $_REQUEST['table'];
$table = 'sources';
$state = $_REQUEST['state'];
$query = "SELECT * from $table where (state='$state' or state='--') order by state, name";
//$query = "SELECT * from $table where (state='$state') order by name";
$result = mysql_query($query); 
$rows = 0;
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
	$output[] = $row;
	$rows = $rows + 1;
}
$data = json_encode($output);  //encode the data in json format
echo '({"total":"' . $rows . '","results":' . $data . '})';
?>
